<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box">box</div>  
</body>
<script>
    // var birth = 2000;
    //  var obj = {
    //      birth: 1990,
    //      getAge: () => {
    //         console.log(new Date().getFullYear() - this.birth); // this指向window
    //      }
    //      }
    //      obj.getAge();
</script>
<script>
    var obj = {
        birth: 1990,
        getAge: ()=> {
            var fn = () => {
                return new Date().getFullYear() - this.birth; // this指向obj
            }
            return fn();
        }
    }
    console.log(obj.getAge());
</script>
<script>
    document.getElementById("box").onclick = function() {
        console.log(this);   //指向div
        setInterval(() => {
            console.log(this);  //指向div
        },1000)
    }
</script>
</html>